#include <variant>
#include <iostream>
#include <vector>

// 使用 std::visit 和 lambda 表达式处理多种类型
void process_variants(const std::variant<int, double, std::string>& v) {
    std::visit([](auto&& arg) {
        using T = std::decay_t<decltype(arg)>;
        if constexpr (std::is_same_v<T, int>)
            std::cout << "Processing int: " << arg << '\n';
        else if constexpr (std::is_same_v<T, double>)
            std::cout << "Processing double: " << arg << '\n';
        else if constexpr (std::is_same_v<T, std::string>)
            std::cout << "Processing string: " << arg << '\n';
    }, v);
}

int main() {
    std::vector<std::variant<int, double, std::string>> vec = {10, 3.14, "variant"};
    for (const auto& v : vec) {
        process_variants(v);
    }
}